<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<a href="javascript:void(0);" onclick="$('#win_create_msg').dialog('close');" class="window-close"></a>
 <div class="tc_top fl"><h2>发送消息</h2></div>
		<div class="tc_add fl">
	        <form id="win_msg_form" method="post" action="${ctx}/msg/add.do">
	        <div class="tc-time">
	            <h2 class="font_s">预约日期</h2>
	            <div class="tc-date">
		            <c:choose>
					   <c:when test="${msg != null}">
					   		<input name="id" type="hidden" value="${param['id']}"/>
							从
			                <input name="msg.startDate" type="hidden" value="<fmt:formatDate value="${msg.startDate}" type="date" pattern="yyyy-MM-dd"/>"/> 
			                <fmt:formatDate value="${msg.startDate}" type="date" pattern="yyyy-MM-dd"/>
			                到
			                <input name="msg.endDate" type="hidden" value="<fmt:formatDate value="${msg.endDate}" type="date" pattern="yyyy-MM-dd"/>"/>
			                <fmt:formatDate value="${msg.endDate}" type="date" pattern="yyyy-MM-dd"/>
					   </c:when>
					   <c:otherwise>
							从
			                <input name="msg.startDate" type="text" class="easyui-datebox" data-options="pWidth:7,required:true"/> 
			                到
			                <input name="msg.endDate" type="text" class="easyui-datebox" data-options="pWidth:7,required:true"/> 
					   </c:otherwise>
					</c:choose>
	            </div>
	        </div>
	        <div class="tc-said">
	        	<h2 class="font_s">留言</h2>
	            <textarea name="msg.msgContent" defaultValue="您可以在这里填写问题以及特殊要求等"></textarea>
	        </div>
	        <p class="tc-send"><a id="win_submit" class="easyui-linkbutton tg-btn" href="javascript:void(0);" onclick="submitMsg(this)">确认发送</a></p>
	        </form>
	    </div>

<script type="text/javascript">
var submitMsg = function(buttonObj) {
	frame.submitForm("win_msg_form", buttonObj, function(res) {
        if (res.code == 1) {
        	msg.msg("消息发送成功.");
        	$('#win_create_msg').dialog('close');
        } else {
        	tools.err(res.msg);
        }
    }, function(param) {
    	if($("[name='msg.msgContent']").val() == '' || $("[name='msg.msgContent']").val() == $("[name='msg.msgContent']").attr("defaultValue")) {
    		msg.warning("没有填写消息内容！");
    		return false;
    	}
    	var userId = "${msg.msgFromId}";
    	if(userId == '') {
    		userId = $("[name='host.userId']").val();
    	}
    	param["msg.userId"]=userId;
    });
};

$(function(){
	$("[name='msg.msgContent']").prompt();

});
</script>
</body>
</html>